<template>
  <div class="panel-container">
    <div class="panel-content">
      <div class="panel-title">资产信息-所在地</div>
      <MixChart :chartData="chartData" :xAxis="xAxis" />
      <div class="table-container">
        <div class="table">
          <div class="tr">
            <div class="th"></div>
            <div class="th" v-for="item in data" :key="item.name">{{ item.name }}</div>
          </div>
          <div class="tr">
            <div class="td">2024-05-13</div>
            <div class="td" v-for="item in data" :key="item.name">{{ item.num }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import MixChart from '@/components/ECharts/MixChart.vue'

export default {
  name: 'Panel4',
  components: { MixChart },
  data() {
    return {
      legend: [{ name: '信息量', value: 'num', type: 'bar' }],
      xAxis: [],
      chartData: [],
      data: [],
    }
  },
  mounted() {
    this.data = [
      { name: '河北', num: 140 },
      { name: '辽宁', num: 1400 },
      { name: '黑龙江', num: 140 },
      { name: '上海', num: 1400 },
      { name: '江苏', num: 100 },
      { name: '山东', num: 100 },
      { name: '河南', num: 1400 },
      { name: '广东', num: 100 },
      { name: '广西', num: 1400 },
      { name: '重庆', num: 140 },
      { name: '陕西', num: 100 },
      { name: '甘肃', num: 140 },
    ]
    this.xAxis = this.data.map((item) => item.name)

    this.legend.forEach((item) => {
      this.chartData.push({
        name: item.name,
        data: this.data.map((d) => d[item.value]),
        type: item.type,
      })
    })
  },
  destroyed() {},
  methods: {},
}
</script>

<style scoped lang="scss">
.table-container {
  margin-top: 30px;
  padding: 0 20px;
}
.table {
  border: 1px solid #dcdfe6;
  .tr {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    border-bottom: 1px solid #ebeef5;
    &:last-child {
      border: none;
    }
  }
  .td,
  .th {
    width: 100%;
    height: 30px;
    border-right: 1px solid #ebeef5;
    display: flex;
    justify-content: center;
    align-items: center;
    &:first-child {
      flex-grow: 2;
    }
    &:last-child {
      border: none;
    }
  }
}
</style>
